package cn.kgc.tangcco.controller;

import cn.kgc.tangcco.service.DujitangService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Controller;


@Controller
public class SocketController {
    @Autowired
    private DujitangService dujitangService;

    @Autowired
    private SimpMessagingTemplate messagingTemplate;


    @MessageMapping("/broadcast")
    @Scheduled(cron = "0/10 * * * * ?")
    public void broadcast(){
        this.messagingTemplate.convertAndSend("/topic/game_chat",dujitangService.queryRandom());
    }


}



